package test.h0813;

import java.util.Scanner;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 小华地图寻宝
 * @date 2024/8/13 22:59
 */
public class Main1 {
    //40 40 18
    //1484
    static int m;
    static int n;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        m = sc.nextInt();
        n = sc.nextInt();
        int k = sc.nextInt(); //k

        System.out.println(getResult(m, n, k));
    }

    static int ans = 0;

    private static int getResult(int m, int n, int k) {
        int[][] graph = new int[m][n];
        boolean[][] visited=new boolean[m][n];
        //DFS
        dfs(0, 0, k,visited);
        return ans;
    }

    private static void dfs(int i, int j, int k, boolean[][] visited) {
        if (i >= 0 && i < m && j >= 0 && j < n && digitSum(i)+digitSum(j) <= k&&!visited[i][j]) {
            ans++;
            visited[i][j]=true;//标记当前节点已经被访问了
        }else return;
        dfs(i - 1, j, k,visited); //上
        dfs(i + 1, j, k,visited); //下
        dfs(i, j - 1, k,visited); //左
        dfs(i, j + 1, k,visited); //右
    }

    //求数位和
    private static int digitSum(int num) {
        int sum = 0;
        while (num != 0) {
            sum += num % 10;
            num /= 10;
        }
        return sum;
    }
}
